package com.metro.demo.common.utils.resource;

import java.util.Properties;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

/**
 * 系统资源初始化类
 * 
 * @author xk
 * @2013-4-19
 */
@Scope("singleton")
@Component("_ResInit")
public class ResInit implements ApplicationContextAware{

    @Resource(name = "ehCacheManager")
	public void setCacheManager (CacheManager cm){
        Res.setCacheManager(cm);
    }
	
	@Resource(name = "sqlSessionTemplate")
	public void setSqlSessionTemplate(SqlSessionTemplate smt) {
		Res.setSqlSessionTemplate(smt);
	}

	@Resource(name = "jdbcTemplate")
	public void setJdbcTemplate(JdbcTemplate jt) {
		Res.setJdbcTemplate(jt);
	}

	/*//@Resource(name = "messageSource")
	public void setMessageSource(MessageSource messageSource) {
		Res.setMessageSource(messageSource);
	}*/
	@Resource(name = "properties")
	public void setProperties(Properties properties) {
		Res.setProperties(properties);
	}
	
	@PostConstruct
	public void initRes() {

	}

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        Res.setApplicationContext(applicationContext);
    }
}
